1. Field of the Invention
The invention disclosed and claimed herein generally pertains to an efficient process or method for accessing internal states of an object, in an object oriented programming paradigm. More particularly, the invention pertains to a method of the above type that can substantially reduce the development effort needed to access encapsulated internal states of an object. Even more particularly, the invention pertains to a method of the above type wherein different types of accessor methods can be applied to different states within the same object.
2. Description of the Related Art
Many programming language compilers, and certainly those used in object oriented programming, tend to be quite literal in their syntax. Object oriented programming provides a number of characteristics that are utilized by developers, including encapsulation, manipulation of state and inheritance. An object interface defines operations and methods that may be performed on an object, and extensions such as inheritance enable an object to support operations that are defined by more than one interface. However, all of the operations of an object tend to be quite literal in their use. If an operation or method is not defined by the object, it cannot be called, and compilers will fail if an attempt is made to use operations or methods that don't exist on the object or object interface.
Because of the need for literal definitions, the definitions of objects in object oriented programming tend to be quite wordy or verbose. This places a significant burden on a software code developer who is writing code to provide access to the internal state of an object, particularly if the state is encapsulated. Encapsulation is a type of privacy applied to the data and to some of the methods in a class, to ensure that an object can be changed only through established channels. The burden on the developer may be substantial even when the state is comparatively simple.
Moreover, as is known by those of skill in the art, after the developer has written object oriented programming code, the code must be parsed by a compiler and rendered into object byte code, so that class files can be prepared therefrom. Finally, the class files are executed by a virtual machine (VM) and interpreted thereby. Thus, a great deal of effort can be required, first for writing code and then for extensively processing it, just to gain access to one or more internal states of an object.
At present, it is common to write accessor methods that expose the internal state as a property whose value can be obtained or changed by invoking one of such methods. Accessor methods can be getters, setters or both getters and setters, as further defined hereinafter. These methods are often boilerplate and provide little value. However, the developer is still forced to write them, since they are necessary for encapsulation. In the past, one of the ways that boilerplate code has been addressed is through macro code. This allows boilerplate code to be processed at compilation time. However, macro code maintenance has its own set of problems, particularly in determining what parts of the code need to be compiled when macros are changed or require debugging. Macros are generated inline, and therefore the expanded code must be syntactically proper for the macro generation. Macros also cause code to be generated in every use case, which can cause code bloat that developers aren't aware of.
In view of the current state of the art, it would be beneficial to provide a simpler and more efficient process for exposing or allowing access to internal states of objects, and to data values associated therewith.